Electronic control unit for vehicle and data communication method

ABSTRACT

An electronic control unit for a vehicle includes a nonvolatile memory that is capable of erasing and writing data electrically, and capable of receiving a program to be written into the nonvolatile memory in units of a predetermined size by means of communication using a communication buffer. The electronic control unit for the vehicle uses communication buffers, the number of which is greater than the number of communication buffers used in an in-vehicle communication environment, to receive the program.

CROSS-REFERENCE TO RELATED PATENT APPLICATIONS

This application is a divisional application of U.S. application Ser.No. 14/219,407, filed on Mar. 19, 2014, which is a continuation ofPCT/JP2012/071791, filed on Aug. 29, 2012, which claims benefit ofpriority from the prior Japanese Patent Application No. 2011-205439,filed Sep. 21, 2011, the entire contents of all of which areincorporated herein by reference.

BACKGROUND

The present invention relates to an electronic control unit for avehicle and to a data communication method.

An electronic control unit (ECU) for a vehicle is equipped with anonvolatile memory (e.g., flash read only memory (ROM)) that is capableof erasing and writing data electrically. The electronic control unitcontrols in-vehicle units (e.g., fuel injector) by means of a controlprogram or the like stored in the nonvolatile memory.

As disclosed in Japanese Laid-open Patent Application Publication No.2008-146521, when data of a control program or the like is written intoa nonvolatile memory, a writing tool, which transfers data to be writtento an electronic control unit, is connected to the electronic controlunit. Then, while transferring the data to be written from the writingtool to the electronic control unit, the electronic control unit writesthe data to be written, into a nonvolatile memory.

The electronic control unit communicates with communication targetunits, using communication buffers different for each of thecommunication target units. Thus, when the electronic control unitreceives the data to be written transferred by the writing tool, theelectronic control unit can use only an assigned communication bufferfor communication with the writing tool, and accordingly, size of datawhich can be received at once is restricted. Thus, for example, in acase of communication in which synchronization is performed in a mannerin which every time the data is received from the writing tool, aresponse thereof is sent to the writing tool, the electronic controlunit sends responses the same number of times as the data to be writtenis received. Accordingly, the number of times of the communicationbetween the electronic control unit and the writing tool may be large,and this may be a cause of increased transfer time of the data to bewritten.

SUMMARY OF THE INVENTION

An electronic control unit for a vehicle includes a nonvolatile memorythat is capable of erasing and writing data electrically, and capable ofreceiving a program to be written into the nonvolatile memory in unitsof a predetermined size by means of communication using a communicationbuffer. The electronic control unit uses communication buffers, thenumber of which is greater than the number of communication buffers usedin an in-vehicle communication environment, to receive the program.

Other objects and features of aspects of the present invention will beunderstood from the following description with reference to theaccompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an explanatory view of an ECU manufacturing process and anapplication program writing process;

FIG. 2 is a configuration view of an ECU and a writing tool;

FIG. 3 is a detailed view of communication buffer areas;

FIG. 4 is a flowchart of a procedure of an application program writingprocess;

FIG. 5 is a view of the outline of entire program-writing processing;

FIG. 6 is a detailed view of the communication buffer areas after acommunication environment is changed;

FIG. 7 is a flowchart of processing performed by a data transfer programof the writing tool;

FIG. 8 is a flowchart of processing performed by the data transferprogram of the writing tool;

FIG. 9 is a flowchart of processing performed by the data transferprogram of the writing tool;

FIG. 10 is a flowchart of processing performed by the data transferprogram of the writing tool;

FIG. 11 is a flowchart of processing performed by a RAM expansionprogram of the ECU;

FIG. 12 is a flowchart of processing performed by a writing main programof the ECU;

FIG. 13 is a flowchart of processing performed by the writing mainprogram of the ECU;

FIG. 14 is a flowchart of processing performed by the writing mainprogram of the ECU;

FIG. 15 is a flowchart of processing performed by the writing mainprogram of the ECU;

FIG. 16 is a flowchart of processing performed by a writing subprogramof the ECU; and

FIG. 17 is a sequence chart of an example of transfer and writingprocessing of the application program.

DETAILED DESCRIPTION

Hereinafter, embodiments for carrying out of the present invention willbe described in detail with reference to the accompanying drawings.

FIG. 1 illustrates an ECU manufacturing process 10 and an applicationprogram writing process 20 for writing an application program (e.g.,engine control program) into a ROM (e.g., flash ROM) incorporated in anECU 100.

In ECU manufacturing process 10, an operator writes a minimum programcapable of executing a hardware checking program and writing anapplication program in a later process, into the ROM incorporated in ECU100, to conduct an inspection. ECU manufacturing process 10 is, forexample, a part of a working process of an ECU supplier or the like.

In application program writing process 20, the operator uses a writingtool 200 to write an application program corresponding to the type ofvehicle into the ROM on ECU 100. Thus, ECU 100 supplied from ECUmanufacturing process 10 is ECU 100 for each type of vehicle. In a laterinspection process, the operator checks whether an application programcorresponding to a vehicle is written into the ROM of ECU 100 assembledin the vehicle. Furthermore, application program writing process 20 is,for example, a part of a working process performed in association withan ECU assembling process at an automobile factory or the like.

Thus, since ECU 100 is common among all types of vehicles before writingan application program into the ROM in application program writingprocess 20, the ECU supplier or the like may, for example, manufactureECUs common to all types of vehicles and deliver the ECUs to theautomobile factory or the like. This eliminates the need for the ECUsupplier or the like to do programming, manufacturing, deliverymanagement and the like of ECU 100 for each type of vehicle. This alsoeliminates the need to maintain and manage (stock status and the likeof) ECU 100 for each type of vehicle before writing into ROM inapplication program writing process 20 at the automobile factory or thelike. Thus, these processes have the advantages of enabling largereductions in manufacturing, management and the like at the ECUsupplier, the automobile factory and the like.

However, application program writing process 20 that did not exist inthe conventional is newly added at the automobile factory or the like.In this application program writing process 20, it is required to writea vehicle type-specific application program into the ROM promptly. FIG.2 illustrates a configuration of ECU 100 and writing tool 200 to meetthis requirement.

ECU 100 controls fuel injection, ignition and the like in a vehicleengine, and includes a ROM 110, a microcomputer 120, a random accessmemory (RAM) 130 as a volatile memory, and a communication circuit 140.ECU 100 is removably connected to writing tool 200 through acommunication line 300 such as a controller area network (CAN).

Microcomputer 120 includes a CPU, a cache memory and the like, toexecute various programs stored in ROM 110 and RAM 130.

In RAM 130, a first buffer area 133 and a second buffer area 134 arepreallocated. First buffer area 133 and second buffer area 134 are usedupon writing data into ROM 110.

In communication circuit 140, a communication buffer area 141 ispreallocated. Communication buffer area 141 is used when ECU 100communicates with another unit through communication circuit 140.

Writing tool 200 includes a storage 210 (e.g., hard disk) and acommunication circuit 240. Writing tool 200 also includes a terminal(e.g., personal computer) and a unit which connects to ECU 100, so thatthe operator can interactively instruct writing tool 200. Writing tool200 transfers data to be written stored in storage 210 to ECU 100.

In storage 210, an application program and the like to be transferred toECU 100 is stored.

In communication circuit 240, a communication buffer area 241 ispreallocated. Communication buffer area 241 is used when writing tool200 communicates with ECU 100 through communication circuit 240.

Here, the details of communication buffer area 141 used when ECU 100communicates with writing tool 200 will be illustrated in FIG. 3.

In communication buffer area 141 of ECU 100, there is a plurality ofgiven-size communication buffers (e.g., mail boxes in CAN). Whencommunicating with each unit, ECU 100 uses a communication bufferpreassigned for communication with a communication target unit among thecommunication buffers in communication buffer area 141. In this case,each communication buffer is divided into a transmit buffer (TX) used tosend data and a receive buffer (RX) used to receive data. Here, thenumber of communication buffers preassigned for communication with acommunication target unit is set to the number of buffers used in anin-vehicle communication environment.

On the other hand, there is a plurality of given-size communicationbuffers in communication buffer area 241 of writing tool 200. The sizeof each communication buffer in communication buffer area 241 is thesame as the size of each communication buffer in communication bufferarea 141 of ECU 100.

In FIG. 3, two communication buffers (one TX1 and one RX1) are assignedin communication buffer area 141 of ECU 100 as communication buffers(communication buffers for writing tool) used by ECU 100 to communicatewith writing tool 200. The other communication buffers in communicationbuffer area 141 are assigned for communication with units other thanwriting tool 200.

Therefore, in a case in which the size of the communication buffer iseight bytes and ECU 100 communicates with writing tool 200 insynchronization with each other to return a response each time itreceives one piece of data to writing tool 200, since one RX is used toreceive one piece of data, ECU 100 needs to perform communication 16times in order to receive 64 bytes of data. In other words, sincewriting tool 200 transfers 64 bytes of data by dividing it into eightbytes of data and ECU 100 returns a response to writing tool 200 eachtime it receives eight bytes, the number of communications is 16.

FIG. 4 illustrates a procedure in application program writing process20.

In step 1 (abbreviated as “S1” in the drawing; the same applieshereinafter), the operator connects ECU 100 to writing tool 200. Onceconnected, ECU 100 is powered on and microcomputer 120 executes theminimum program to make ECU 100 communicable with writing tool 200,waiting for receiving data to be transferred from writing tool 200.

In step 2, the operator specifies an application program (e.g., enginecontrol program for vehicle type A) and the like to be written into ROM110. When an application program is specified, writing tool 200transfers the specified application program to ECU 100. ECU 100 writesthe application program into ROM 110 while receiving the transferredapplication program and the like. Hereinafter, processing in step 2 iscalled entire program-writing processing.

In step 3, the operator disconnects ECU 100 from writing tool 200.

After that, ECU 100 is assembled in each vehicle. Furthermore, in theinspection process, it is checked whether a proper application programis written into ROM 110 of ECU 100 (e.g., whether it is an applicationprogram corresponding to the vehicle in which ECU 100 is assembled). Ifthe proper application program is not written, writing tool 200 isreconnected to ECU 100 assembled in the vehicle, to write a properapplication program.

FIG. 5 illustrates the outline of the entire program-writing processing.

In step 11, when the operator specifies a writing program and anapplication program to be written into ROM 110, writing tool 200activates a data transfer program that transfers the writing program andthe application program. Then, writing tool 200 sends ECU 100 a messageindicative of the start of transfer of the writing program (e.g.,writing program 2) by means of the data transfer program, and transfersthe specified writing program.

Here, the writing program specified by the operator is stored in awriting program database 211 existing in storage 210. The writingprogram is transferred to ECU 100, to perform, on ECU 100,initialization processing such as to change a communication environment,receiving processing of data to be written, and processing for writingthe data to be written into ROM 110. The writing program is composed ofa writing main program and a writing subprogram.

The writing main program runs on ECU 100 after being transferred to ECU100, to establish a communication environment (method of usingcommunication buffers, communication speed, encryption scheme and thelike) corresponding to the writing program between writing tool 200 andECU 100. Furthermore, the writing main program writes the applicationprogram transferred from writing tool 200 into ROM 110 according towriting conditions (address of a write area in the ROM and the like)corresponding to the writing program. The writing subprogram isactivated by the writing main program, to copy received data incommunication buffer area 141 to a first buffer area and a second bufferarea.

Furthermore, the application program specified by the operator is storedin an application program database 212 existing in storage 210. Eachapplication program is an engine control program or the likecorresponding to each type of vehicle.

In step 12, when ECU 100 receives the message indicative of the start oftransfer of the writing program from writing tool 200 as the source ofthe writing program, a RAM expansion program stored in ROM 110 isactivated. Here, the RAM expansion program performs processing forexpanding, in RAM 130, the writing program received by ECU 100. Thus,while receiving the writing program, ECU 100 expands the receivedwriting program in RAM 130 by means of the RAM expansion program.

In step 13, when ECU 100 completes the expansion of the writing program,the writing program expanded in RAM 130 is activated by the RAMexpansion program.

In step 14, ECU 100 has the writing program change the communicationenvironment between ECU 100 and writing tool 200 to a communicationenvironment corresponding to the writing program, and sends writing tool200 a message requesting transmission of an application program.

In step 15, when writing tool 200 receives the message requesting thetransmission of an application program, transfer of an applicationprogram (e.g., application program 1) specified by the operator to ECU100 is started by means of the data transfer program.

In step 16, while receiving the application program from writing tool200, ECU 100 writes the received application program into ROM 110 basedon the writing conditions by means of the writing main program and thewriting subprogram.

After completion of writing, ECU 100 is disconnected from writing tool200, and hence the power is turned off. When the power of ECU 100 isturned on next, the communication environment of ECU 100 is restored toan initial state (the same communication environment as in step 1). In acase in which some kind of malfunction (e.g., communication with writingtool 200 is cut off or the like while the writing program is running)has occurred during the entire program-writing processing, ECU 100resets itself. Then, the communication environment of ECU 100 isrestored to the initial state.

Thus, by selecting a writing program, the writing program appropriatefor the communication environment used, the writing conditions for theapplication program, and the like can run in the entire program-writingprocessing. Therefore, for example, a writing program with highercommunication speed can run to perform high-speed communication, so asto speed up the entire program-writing processing.

Furthermore, in the entire program-writing processing, the writingprogram is transferred to ECU 100, and this eliminates the need to storethe writing program in ROM 110, enabling reduction in usage of ROM 110.

Furthermore, by changing the writing program, a new function can beadded in the entire program-writing processing.

In such a situation that any other unit is connected to ECU 100 inaddition to writing tool 200, if ECU 100 blocks the communication withthe other unit to communicate only with writing tool 200, the entireprogram-writing processing can be performed.

As an example of performing the entire program-writing processing insuch a situation that the other unit is connected to ECU 100 in additionto writing tool 200, there is a case in which an application program iswritten in such a state that ECU 100 is assembled in a vehicle.

In this case, a communication environment used when ECU 100 communicateswith writing tool 200 needs to be a communication environment common tothe other unit (e.g., the communication speed is common) in order toprevent competition between communication channels. Therefore, theoperator specifies a writing program which can establish a communicationenvironment common to the other unit, to perform the entireprogram-writing processing. At this time, ECU 100 communicates only withwriting tool 200, blocking communication with the other unit.

Next, a method of using communication buffer area 141 used when ECU 100receives an application program transferred from writing tool 200 willbe described.

In application program writing process 20, since ECU 100 does notcommunicate with any unit other than writing tool 200, a communicationbuffer preassigned to the unit other than writing tool 200(communication buffer for the other unit) is not used.

Thus, the writing program can change the communication buffer for theother unit to be used for communication between ECU 100 and writing tool200 in addition to the communication buffer for writing tool.

FIG. 6 illustrates the details of communication buffer area 141 afterbeing changed.

In the example of FIG. 6, when communicating with writing tool 200, ECU100 uses two communication buffers for writing tool and sevencommunication buffers in communication buffers for other units. At thistime, one TX and eight RXs are set as the nine communication buffersused by ECU 100. At this time, communication buffers in communicationbuffer area 241 of writing tool 200 are eight TXs and one RX.

For example, in a case in which the size of one communication buffer iseight bytes and ECU 100 communicates with writing tool 200 insynchronization with each other to return a response to writing tool 200each time one piece of data is received, since eight RXs can be used toreceive one piece of data, ECU 100 just has to perform communicationnine times to receive 64 bytes of data from writing tool 200. In otherwords, writing tool 200 transfers 64 bytes of data by dividing it intoeight bytes of data as one piece of data, and ECU 100 returns a responseto writing tool 200 each time eight pieces of eight-byte data arereceived. Thus, the number of communications is nine.

The writing program may set the number of communication buffers used forECU 100 to communicate with writing tool 200 to a number according tothe size of data to be sent and received, an integral multiple of thesize of data to be sent and received, the size of one write into ROM110, an integral multiple of the size of one write into ROM 110, or thelike.

Thus, since communication can be performed by using communicationbuffers for other units in addition to communication buffers for writingtool, the number of communications in the case of communicationrequiring synchronization can be reduced, reducing the time required totransfer data and hence speeding up the transfer of data. Furthermore,since communication buffers for other units are used, writing tool 200can continuously transfer data without taking into account overwritingof communication buffers.

In communication buffer area 141, if there is any unused communicationbuffer that is not assigned to any unit, the writing program can use theunused communication buffer for communication between ECU 100 andwriting tool 200. Since this increases the size of communication buffercapable of being used for receiving one piece of data, the number ofcommunications can be further reduced.

Next, each program running in the entire program-writing processing willbe described.

FIG. 7 and FIG. 8 illustrate flowcharts of processing performed by thedata transfer program on writing tool 200 when the writing program andthe application program are specified by the operator on writing tool200.

In step 31, the data transfer program sends ECU 100 a message (writingprogram transfer starting message) indicative of the start of transferof the writing program.

In step 32, the data transfer program sequentially transfers data of thespecified writing program by an amount of data size that ECU 100 canreceive in one communication.

In step 33, the data transfer program determines whether a next datarequest message was received from ECU 100. When the next data requestmessage was received from ECU 100, the data transfer program proceedsthe processing to step 34 (Yes), whereas when the next data requestmessage is not received from ECU 100, the data transfer program returnsthe processing to step 33 (No).

In step 34, the data transfer program determines whether the transfer ofthe specified writing program has been completed. When the transfer ofthe specified writing program has been completed, the data transferprogram proceeds the processing to step 35 (Yes), whereas when thetransfer of the specified writing program is not completed, the datatransfer program returns the processing to step 32 (No).

In step 35, the data transfer program sends ECU 100 a message indicativeof completion of the transfer of the writing program (writing programtransfer completion message).

In step 36, the data transfer program determines whether a message wasreceived from ECU 100. When a message was received from ECU 100, thedata transfer program proceeds the processing to step 37 (Yes), whereaswhen no message is received from ECU 100, the data transfer programreturns the processing to step 36 (No).

In step 37, the data transfer program determines whether the messagereceived from ECU 100 is a message indicating that the writing programwas transferred correctly. When the received message is the messageindicating that the writing program was transferred correctly, the datatransfer program proceeds the processing to step 38 (Yes), whereas whenthe received message is not the message indicating that the writingprogram was transferred correctly, the data transfer program proceedsthe processing to step 39 (No).

In step 38, the data transfer program executes an application transferprocessing subroutine. The application transfer processing subroutine isto perform processing for dividing and transferring data of thespecified application program. Hereinafter, the data divided andtransferred is called divided data.

In step 39, the data transfer program is set to transfer the writingprogram again from the beginning (e.g., return the index of the writingprogram to the beginning or the like). After that, the data transferprogram returns the processing to step 32.

FIG. 9 and FIG. 10 illustrate flowcharts of processing of theapplication transfer processing subroutine.

In step 41, the data transfer program determines whether writing tool200 received a message from ECU 100. When a message was received fromECU 100, the data transfer program proceeds the processing to step 42(Yes), whereas when no message is received from ECU 100, the datatransfer program returns the processing to step 41 (No).

In step 42, the data transfer program determines whether the receivedmessage is any message other than a message indicative of a transmissionrequest for divided data (divided data transmission request message).When the received message is a message other than the divided datatransmission request message, the data transfer program proceeds theprocessing to step 43 (Yes), whereas when the received message is thedivided data transmission request message, the data transfer programproceeds the processing to step 44 (No).

In step 43, the data transfer program determines whether the receivedmessage is any message other than the message indicative of theretransmission request for divided data (divided data retransmissionrequest message). When the received message is a message other than thedivided data retransmission request message, the data transfer programproceeds the processing to step 47 (Yes), whereas when the receivedmessage is the divided data retransmission request message, the datatransfer program proceeds the processing to step 46 (No).

In step 44, the data transfer program reads data from a position, towhich a read pointer representing the index of the specified applicationprogram points, and creates divided data with a checksum added to theread data. Here, the size of reading data is set to a value obtained bysubtracting the size of the checksum from the total size of RXs used inthe communication environment established by the transferred writingprogram on ECU 100.

The initial value of the read pointer is the start address of theapplication program. Each time step 44 is executed, the read pointer isincremented by the size of reading data.

For example, in a case in which the total size of RXs used in thecommunication environment established by the transferred writing programis 64 bytes and the size of the checksum is two bytes, the size ofreading data is 62 bytes and the size of divided data is 64 bytes.

For data verification, there is cyclic redundancy check (CRC) inaddition to the checksum. Furthermore, it may be checked whether divideddata is received in the right order in such a manner that at the side ofwriting tool 200, divided data includes a sequence number indicating howmany pieces of divided data preceded before the divided data istransferred, and at the side of ECU 100 checks on the sequence number ofthe received divided data.

In step 45, the data transfer program transfers the created divided datato ECU 100. At this time, the data transfer program divides the divideddata by the size of TX in communication buffer area 241 and stores eachpiece in each TX in communication buffer area 241 to transfer thedivided data. For example, in a case in which the divided data is 64bytes and there are eight TXs, each of which is eight bytes, incommunication buffer area 241, the data transfer program divides thedivided data into eight pieces of eight-byte data and stores each piecein each TX.

The data stored in the TX is transferred to ECU 100 by means ofcommunication circuit 240.

In step 46, the data transfer program transfers the created divided dataagain to ECU 100.

In step 47, the data transfer program determines whether the receivedmessage is any message other than a message indicating that the divideddata was not written correctly into ROM 110 of ECU 100 (divided datawriting NG message). When the received message is any message other thanthe divided data writing NG message, the data transfer program proceedsthe processing to step 48 (Yes), whereas when the received message isthe divided data writing NG message, the data transfer program proceedsthe processing to step 50 (No).

In step 48, the data transfer program determines whether the transfer ofthe application program has been completed to the end based on whetherthe read pointer has been reached the end of the application program.When the transfer of the application program has been completed to theend, the data transfer program proceeds the processing to step 49 (Yes),whereas when the transfer of the application program is not completed tothe end, the data transfer program returns the processing to step 41(No).

In step 49, the data transfer program sends ECU 100 a message indicativeof completion of the transfer of the application program (applicationtransfer completion message).

In step 50, the data transfer program sets the value of the read pointerto a start address of the application program to transfer theapplication program again from the beginning. After that, the datatransfer program returns the processing to step 41.

FIG. 11 illustrates a flowchart of processing performed by the RAMexpansion program on ECU 100 when ECU 100 received the writing programtransfer starting message.

In step 51, the RAM expansion program determines whether ECU 100received data from writing tool 200. When ECU 100 received data fromwriting tool 200, the RAM expansion program proceeds the processing tostep 52 (Yes), whereas when ECU 100 does not received data from writingtool 200, the RAM expansion program returns the processing to step 51(No).

In step 52, the RAM expansion program determines whether the receiveddata is a writing program transfer completion message. When the receiveddata is the writing program transfer completion message, the RAMexpansion program proceeds the processing to step 53 (Yes), whereas whenthe received data is not the writing program transfer completionmessage, the RAM expansion program proceeds the processing to step 56(No).

In step 53, the RAM expansion program determines whether the transferredwriting program is valid by using the checksum or the like. When thetransferred writing program is valid, the RAM expansion program proceedsthe processing to step 54 (Yes), whereas when the transferred writingprogram is not valid, the RAM expansion program proceeds the processingto step 58 (No).

In step 54, the RAM expansion program sends writing tool 200 a messageindicating that the writing program is transferred correctly.

In step 55, the RAM expansion program activates the writing main programin the writing program expanded in RAM 130.

In step 56, the RAM expansion program expands, in RAM 130, the receiveddata of the writing program from RX in communication buffer area 141.

In step 57, the RAM expansion program sends writing tool 200 a next datarequest message. After that, the RAM expansion program returns theprocessing to step 51.

In step 58, the RAM expansion program sends writing tool 200 a messageindicating that the writing program is not transferred correctly. Afterthat, the RAM expansion program returns the processing to step 51.

FIG. 12 illustrates a flowchart of processing performed by the writingmain program on ECU 100 when the writing main program is activated.

In step 61, according to the transferred writing program, the writingmain program changes the communication environment in which ECU 100communicates with writing tool 200. When ECU 100 is communicable withany unit other than writing tool 200, the communication environment maynot be changed.

In step 62, the writing main program executes a ROM writing processingsubroutine. The ROM writing processing subroutine is to receive divideddata from writing tool 200 as the source of the divided data and writedata of the application program into ROM 110 based on the divided data.

FIG. 13 to FIG. 15 illustrate the ROM writing processing subroutine.

In step 71, the writing main program sets first buffer area 133 as acopy area for copying divided data received from writing tool 200.

In step 72, the writing main program activates a writing subprogram.

In step 73, the writing main program substitutes 1 into a variable n asa counter representing how many pieces of data preceded before a pieceof data being processed in the data (data of the application program) tobe written into ROM 110.

In step 74, the writing main program sends writing tool 200 a divideddata transmission request message to receive first divided data.

In step 75, the writing main program determines whether a message(divided data copy completion message) indicating that divided datareceived from writing tool 200 was copied to the copy area has beennotified from the writing subprogram. When the divided data copycompletion message has been notified, the writing main program proceedsthe processing to step 76 (Yes), whereas when the divided data copycompletion message is not notified, the writing main program returns theprocessing to step 75 (No).

In step 76, the writing main program refers to the first divided datastored in the copy area, to use the checksum included in the divideddata, so as to determine whether the first divided data was receivedcorrectly. When the first divided data was received correctly, thewriting main program proceeds the processing to step 77 (Yes), whereaswhen the first divided data was not received correctly, the writing mainprogram proceeds the processing to step 78 (No).

In step 77, the writing main program sets first buffer area 133 as awrite area used when divided data is written into ROM 110 and setssecond buffer area 134 as the copy area.

In step 78, the writing main program sends writing tool 200 a divideddata retransmission request message to re-receive the first divideddata. After that, the writing main program returns the processing tostep 75. A message (divided data receiving NG message) indicating thatthe divided data was not received correctly may also be sent to writingtool 200 together with the divided data retransmission request message.

In step 79, the writing main program sends writing tool 200 a divideddata transmission request message to receive second divided data. Amessage (divided data receiving OK message) indicating that the previousdivided data was received correctly may also be sent to writing tool 200together with the divided data transmission request message.

In step 80, the writing main program removes the checksum from n^(th)divided data stored in the write area and writes, into ROM 110, the datastored in the write area according to the writing conditions.

In step 81, the writing main program verifies the write data todetermine whether the nth data was written into ROM 110 correctly. Whenthe n^(th) data was written into ROM 110 correctly, the writing mainprogram proceeds the processing to step 82 (Yes), whereas when then^(th) data was not written into ROM 110 correctly, the writing mainprogram proceeds the processing to step 84 (No).

The write data is verified by comparing, for example, the content of thewrite area with the content of a written area of ROM 110.

In step 82, the writing main program determines whether the divided datacopy completion message has been notified from the writing subprogram.When the divided data copy completion message has been notified, thewriting main program proceeds the processing to step 83 (Yes), whereaswhen the divided data copy completion message is not notified, thewriting main program returns the processing to step 82 (No).

In step 83, the writing main program determines whether the data storedin the copy area is the application transfer completion message. Whenthe data stored in the copy area is the application transfer completionmessage, the writing main program terminates the processing (Yes),whereas when the data stored in the copy area is not the applicationtransfer completion message, the writing main program proceeds theprocessing to step 87 (No).

In step 84, the writing main program sends writing tool 200 a divideddata writing NG message.

In step 85, the writing main program erases data in the written area ofROM 110.

In step 86, the writing main program sets first buffer area 133 as thecopy area.

In step 87, the writing main program verifies, based on the checksum,(n+1)^(th) divided data copied in the copy area to determine whether the(n+1)^(th) divided data was received correctly. When the (n+1)^(th)divided data was received correctly, the writing main program proceedsthe processing to step 88 (Yes), whereas when the (n+1)^(th) divideddata was not received correctly, the writing main program proceeds theprocessing to step 91 (No). The (n+1)^(th) divided data may be verifiedby the writing subprogram immediately after the (n+1)^(th) divided datais received.

In step 88, the writing main program changes, to the write area, thebuffer area set for copying, and changes, to the copy area, the bufferarea set for writing.

In step 89, the writing main program sends writing tool 200 a divideddata transmission request message to receive (n+2)^(th) divided data.

Together with the divided data transmission request message, a message(divided data writing OK message) indicating that the n^(th) divideddata was written into ROM 110 and a message (divided data receiving OKmessage) indicating that the (n+1)^(th) divided data was received may besent to writing tool 200.

In step 90, after adding 1 to n, the writing main program returns theprocessing to step 80.

In step 91, the writing main program sends writing tool 200 a divideddata retransmission request message to re-receive the (n+1)^(th) divideddata. After that, the writing main program returns the processing tostep 82. Together with the divided data retransmission request message,a message (divided data receiving NG message) indicating that the(n+1)^(th) divided data was not received correctly may be sent towriting tool 200.

FIG. 16 illustrates a flowchart of processing performed by the writingsubprogram on ECU 100 when ECU 100 received data from writing tool 200.

In step 101, the writing subprogram copies received divided data from RXof communication buffer area 141 to the copy area.

In step 102, the writing subprogram notifies the writing main program ofa divided data copy completion message.

The copy area may be set to an area corresponding to RX of communicationbuffer area 141, so that ECU 100 may use the copy area to receive data.In this case, there is no need to copy divided data from RX ofcommunication buffer area 141 to the copy area.

Furthermore, in a case in which there is a difference between processingtime from the divided data transmission request to completion of copyingand the time required for writing of data into ROM 110 and verification,processing for receiving next divided data and processing for writingdata into ROM 110 may be started upon completion of either one of theprocessings that takes a longer time.

Thus, two buffer areas are prepared for writing received divided datainto ROM 110 in parallel with receiving divided data through RX. Then,the two buffer areas are so used that when one buffer area is used forprocessing to write into ROM 110, the other buffer area is used forprocessing for ECU 100 to copy the received divided data. Here, thebuffer area used for write processing and the buffer area used for copyprocessing are switched therebetween each time the respective processingis performed. This enables ECU 100 to perform, in parallel, processingfor writing data into ROM 110 using one buffer area and processing forreceiving divided data and copying received divided data to the otherbuffer area. Therefore, the time required for the entire program-writingprocessing can be shortened.

Furthermore, since processing on ECU 100 side has only to be changed toperform these processing, the time required for the entireprogram-writing processing can be shortened without changing writingtool 200 substantially.

A sequence of an example of the application program transfer and writingprocessing will be as illustrated in FIG. 17. Here, the size of theprogram transferred by writing tool 200 is 180 bytes. Furthermore, thetotal size of respective RXs of ECU 100 is 64 bytes.

ECU 100 sends writing tool 200 a first divided data transmission requestmessage.

Among pieces of data of the application program, writing tool 200 readsfirst 62 bytes of data, creates first divided data with two bytes ofchecksum added thereto, and transfers the first divided data to ECU 100.

After receiving the first divided data, ECU 100 copies the first divideddata from RX of communication buffer area 141 to first buffer area 133.Next, ECU 100 verifies the first divided data and sends writing tool 200a second divided data transmission request message. Furthermore, ECU 100uses first buffer area 133, to perform processing for writing data intoROM 110 and verification of write data.

When receiving the second divided data transmission request message,writing tool 200 reads 62 bytes of data to be transferred next, createssecond divided data with the checksum added thereto, and transfers thesecond divided data to ECU 100.

After receiving the second divided data, ECU 100 copies the seconddivided data from RX of communication buffer area 141 to second bufferarea 134. Next, ECU 100 verifies the second divided data. Aftercompletion of verification of the second divided data and verificationof the first write data, ECU 100 sends writing tool 200 a third divideddata transmission request message. Furthermore, ECU 100 uses secondbuffer area 134, to perform processing for writing data into ROM 110 andverification of the write.

After receiving the third divided data transmission request message,writing tool 200 reads the remaining 56 bytes of data, creates thirddivided data with the checksum added thereto, and transfers the thirddivided data to ECU 100.

Processing after ECU 100 receives the third divided data is the same asthe processing after receiving the second divided data.

When receiving a fourth divided data transmission request message,writing tool 200 sends ECU 100 an application transfer completionmessage.

The embodiment may also be applied to various electronic control unitseach equipped with a nonvolatile memory. A plurality of ECUs 100 may beconnected to one writing tool 200, so that one writing tool 200transfers, to each ECU 100, data to be written into ROM 110 in atime-shared manner.

Here, a part of the matters described in the embodiments may be replacedor appropriately combined.

While only selected embodiments have been chosen to illustrate thepresent invention, it will be apparent to those skilled in the art fromthis disclosure that various change and modification can be made hereinwithout departing from the scope of the invention as defined in theappended claims.

Furthermore, the foregoing descriptions of the embodiments according tothe present invention are provided for illustration only, and not forthe purpose of limiting the invention as defined by the appended claimsand their equivalents.

What is claimed is:
 1. An electronic control unit for a vehicle,connected to an external writing device that writes at least a controlprogram for controlling the vehicle and a setting program ofcommunication buffers, and comprising a first communication buffer usedfor communication with the external writing device and secondcommunication buffers used for communication with a correspondingexternal device that controls the vehicle, wherein the electroniccontrol unit is configured to communicate using the first and secondcommunication buffers, and the second communication buffers are assignedby the setting program of the communication buffers received from theexternal writing device as the first communication buffer, whereinreceive the control program and data from the external writing deviceusing the first communication buffer and the second communicationbuffers assigned as the first communication buffer, and performprocessing to write data from the external writing device using thefirst communication buffer, which is pre-allocated for communicationwith the external writing device, in parallel with writing data receivedfrom the external writing device to at least one of the secondcommunication buffers, which has been reassigned for communication withthe external device.
 2. The electronic control unit for the vehicleaccording to claim 1, wherein a size of the first communication bufferand a size of each second communication buffer are set based on a sizeof the control program and a size of the data, written into anonvolatile memory that is capable of erasing and writing dataelectrically.
 3. The electronic control unit for the vehicle accordingto claim 1, wherein the setting program of the communication buffersreceived from the external writing device is expanded and activated in avolatile memory that temporarily stores data.
 4. The electronic controlunit of claim 1, wherein the electronic control unit is configured toblock communication with a communication target other than the externalwriting device when the communication target is connected to theelectronic control unit.
 5. The electronic control unit of claim 4,wherein the electronic control unit is configured to use a communicationbuffer preassigned to the communication target when communication withthe communication target is blocked.
 6. The electronic control unit ofclaim 1, wherein the electronic control unit is configured to: receiveinformation using a second communication buffer, which is reassignedfrom another external device, as the first communication buffer.
 7. Theelectronic control unit of claim 1, wherein the electronic control unitis configured to receive application data which has been divided tocreate divided data, the divided data being stored in the externalwriting device and transferred to the electronic control unit accordingto a size of a transmit communication buffer in a communication area ofthe external writing device.
 8. A data communication method for use inan electronic control unit for a vehicle, connected to an externalwriting device that writes at least a control program for controllingthe vehicle and a setting program of communication buffers, andcomprising a first communication buffer used for communication with theexternal writing device and second communication buffers used forcommunication with a corresponding external device that controls thevehicle, the method comprising the steps of: assigning the secondcommunication buffers as the first communication buffer by the settingprogram of the communication buffers received from the external writingdevice; receiving the control program and data from the external writingdevice by using the first communication buffer and the secondcommunication buffers assigned as the first communication buffer, andperforming processing to write data from the external writing deviceusing the first communication buffer, which is pre-allocated forcommunication with the external writing device, in parallel with writingdata received from the external writing device to at least one of thesecond communication buffers, which has been reassigned forcommunication with the external device.
 9. The data communication methodaccording to claim 8, wherein a size of the first communication bufferand a size of each second communication buffer are set based on a sizeof the control program and a size of the data, written into anonvolatile memory that is capable of erasing and writing dataelectrically.
 10. The data communication method according to claim 8,wherein the electronic control unit for the vehicle expands andactivates the setting program of the communication buffers received fromthe external writing device, in a volatile memory that temporarilystores data.
 11. The data communication method of claim 8, furthercomprising: blocking, by the electronic control unit, communication witha communication target other than the external writing device when thecommunication target is connected to the electronic control unit. 12.The data communication method of claim 11, further comprising: using acommunication buffer preassigned to the communication target whencommunication with the communication target is blocked.
 13. The datacommunication method of claim 8, further comprising: receiving, by theelectronic control unit, application data which has been divided tocreate divided data, the divided data being stored in the externalwriting device and transferred to the electronic control unit accordingto a size of a transmit communication buffer in a communication area ofthe external writing device.